/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pazi_laba1;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Mike
 */
public class Auth_handler {
    public String Auth(String login,String pass){
        String answer="false";
        if (login.equals("ADMIN"))
        {answer="admin_true";}
        //проверка на права доступа

           try {
               String line="";
            BufferedReader  bf = new BufferedReader(new FileReader("conf.cfg"));
            while((line = bf.readLine()) != null){
             if(line.equals(login)){
                 line=bf.readLine();
                 if(Integer.toString(line.hashCode()).equals(pass)){
                     if(line.equals("")){answer="new_pass";}
                     else{answer = "true";}
                 }
                else{answer="false";}
             }
             else{answer="false";}  
            }

            bf.close();
        } catch (IOException ex) {
            Logger.getLogger(Admin_handler.class.getName()).log(Level.SEVERE, null, ex);
        }
        return answer;
    }
}
